package com.it.test;

import com.it.config.MainConfigOfProfile;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import javax.sql.DataSource;

public class IOCTest_Profile {


    @Test
    public void test1() {
        AnnotationConfigApplicationContext app = new AnnotationConfigApplicationContext();
        app.getEnvironment().setActiveProfiles("test","dev");
        app.register(MainConfigOfProfile.class);
        app.refresh();

        System.out.println("容器创建完成");
        String[] beanDefinitionNames = app.getBeanNamesForType(DataSource.class);
        for (String beanDefinitionName : beanDefinitionNames) {
            System.out.println(beanDefinitionName);
        }
        app.close();
    }


}
